import 'dart:async';

import 'package:acgn_pioneer/public.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/widgets.dart';
import 'color_util.dart';

/// 获取本地图片信息
Future<ImageInfo> getLocalImageInfo(ImageProvider image) async {
  Completer<ImageInfo> completer = Completer();
  Future<void>(() {
    image
        .resolve(new ImageConfiguration())
        .addListener(new ImageStreamListener((ImageInfo info, bool _) {
      completer.complete(info);
    }));
  });

  return completer.future;
}

Widget getIconNew(bool flag) {
  return flag
      ? Positioned(
          right: 0,
          child: Container(
              height: 16,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.only(bottomLeft: Radius.circular(8)),
                color: ColorUtil.rgba(254, 45, 102, 1),
              ),
              padding: EdgeInsets.only(left: 4, right: 4),
              child: Text('NEW',
                  style: TextStyle(
                      height: 1.4, fontSize: 10, color: Colors.white))))
      : SizedBox.shrink();
}
